package ejb.facades.forum;

import ejb.facades.AbstractFacade;
import entities.forum.Topic;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * Trabalho PD - 2014/2015
 *
 * @author a21210380 a21210392
 */
@Stateless
public class TopicFacade extends AbstractFacade<Topic> implements TopicFacadeLocal {

    @PersistenceContext(unitName = "Trabalho_PDPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public TopicFacade() {
        super(Topic.class);
    }

    @Override
    public List<Topic> findRecent(int top) {
        return em.createNamedQuery("Topic.findRecent", Topic.class)
                .setMaxResults(top)
                .getResultList();
    }
}
